<?php
//测试控制器类
class IndexController extends AuthController{
	
	private $model;

	public function __init(){
		parent::__init();
		$this->model = K('Users');
	}
	
    //动作方法
    public function index(){
        //显示视图
        $this->display();
    }
	
	//显示左边分帧
	public function left(){
		$this->display();
	}
	//显示右边分帧
	public function welcome(){
		$aid = session('aid');
		//查询当前登陆的管理员的信息
		$userInfo = K('Admin')->where("aid={$aid}")->find();
		//查询当前未处理的订单
		$handleCount = K('GoodsOrder')->where("order_status = '已付款'")->count();
		//查询当前未回答的提问
		$questcount = K('Quest')->where("answer=''")->count();
		$this->assign('questcount',$questcount);
		$this->assign('handlecount',$handleCount);
		$this->assign('userInfo',$userInfo);
		$this->display();
	}
	//显示上边分帧
	public function top(){
		$this->display();
	}
	
	/**
	 * 工作台显示一些常规信息和快捷操作
	 */
	 public function workTouch(){
	 	//获得当前会员数
	 	$this->assign('memberNum',$this->model->where('is_admin=0')->count());
		//获得当前商品总数
		$this->assign('goodsNum',K('Goods')->count());
		//获得总库存数
		$this->assign('goodsAllCount',current(K('Goods')->field("sum(goods_count) as count")->all()));
		//最新订单
		$this->assign('newOrder',K('GoodsOrder')->field('oid,order_sn,order_status')->order('order_time DESC')->limit(14)->all());
		//提问数
		$this->assign('questcount',K('Quest')->count());
	 	$this->display();
	 }
	
}
